home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / sprite.X11R3 / RCS / spriteGC.c,v < prev    next >
Encoding:
Text File  |  1989-11-19  |  57.0 KB  |  2,326 lines

  1. head     1.9;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.9
  10. date     89.11.18.20.57.24;  author tve;  state Exp;
  11. branches ;
  12. next     1.8;
  13.  
  14. 1.8
  15. date     88.03.27.21.17.29;  author deboor;  state Exp;
  16. branches ;
  17. next     1.7;
  18.  
  19. 1.7
  20. date     88.02.19.17.42.25;  author deboor;  state Exp;
  21. branches ;
  22. next     1.6;
  23.  
  24. 1.6
  25. date     87.08.04.17.30.39;  author deboor;  state Exp;
  26. branches ;
  27. next     1.5;
  28.  
  29. 1.5
  30. date     87.06.30.19.09.41;  author deboor;  state Exp;
  31. branches ;
  32. next     1.4;
  33.  
  34. 1.4
  35. date     87.06.28.14.21.24;  author deboor;  state Exp;
  36. branches ;
  37. next     1.3;
  38.  
  39. 1.3
  40. date     87.06.24.12.52.26;  author deboor;  state Exp;
  41. branches ;
  42. next     1.2;
  43.  
  44. 1.2
  45. date     87.06.21.19.13.35;  author deboor;  state Exp;
  46. branches ;
  47. next     1.1;
  48.  
  49. 1.1
  50. date     87.06.20.14.55.42;  author deboor;  state Exp;
  51. branches ;
  52. next     ;
  53.  
  54.  
  55. desc
  56. @Functions for preserving the cursor by intercepting output calls through
  57. the GC
  58. @
  59.  
  60.  
  61. 1.9
  62. log
  63. @first working version with CG4 and CG6 for SPARC. CG4 for sun3 not yet ok.
  64. @
  65. text
  66. @/*-
  67.  * spriteGC.c --
  68.  *    Functions to support the meddling with GC's we do to preserve
  69.  *    the software cursor...
  70.  *
  71.  * Copyright (c) 1987 by the Regents of the University of California
  72.  *
  73.  * Permission to use, copy, modify, and distribute this
  74.  * software and its documentation for any purpose and without
  75.  * fee is hereby granted, provided that the above copyright
  76.  * notice appear in all copies.  The University of California
  77.  * makes no representations about the suitability of this
  78.  * software for any purpose.  It is provided "as is" without
  79.  * express or implied warranty.
  80.  *
  81.  *
  82.  */
  83. #ifndef lint
  84. static char rcsid[] =
  85.     "$Header: /b/X/src/cmds/Xsprite/ddx/sun3.md/RCS/spriteGC.c,v 1.8 88/03/27 21:17:29 deboor Exp Locker: mgbaker $ SPRITE (Berkeley)";
  86. #endif lint
  87.  
  88. #include    "spriteddx.h"
  89.  
  90. #include    "Xmd.h"
  91. #include    "extnsionst.h"
  92. #include    "regionstr.h"
  93. #include    "windowstr.h"
  94. #include    "fontstruct.h"
  95. #include    "dixfontstr.h"
  96. #include    "../mi/mifpoly.h"        /* for SppPointPtr */
  97. #ifdef foobarsun4
  98. #include    "alloca.h"
  99. #include    "stdio.h"
  100. #endif
  101.  
  102. /*
  103.  * Overlap BoxPtr and Box elements
  104.  */
  105. #define BOX_OVERLAP(pCbox,X1,Y1,X2,Y2) \
  106.      (((pCbox)->x1 <= (X2)) && ((X1) <= (pCbox)->x2) && \
  107.      ((pCbox)->y1 <= (Y2)) && ((Y1) <= (pCbox)->y2))
  108.  
  109. /*
  110.  * Overlap BoxPtr, origins, and rectangle
  111.  */
  112. #define ORG_OVERLAP(pCbox,xorg,yorg,x,y,w,h) \
  113.     BOX_OVERLAP((pCbox),(x)+(xorg),(y)+(yorg),(x)+(xorg)+(w),(y)+(yorg)+(h))
  114.  
  115. /*
  116.  * Overlap BoxPtr, origins and RectPtr
  117.  */
  118. #define ORGRECT_OVERLAP(pCbox,xorg,yorg,pRect) \
  119.     ORG_OVERLAP((pCbox),(xorg),(yorg),(pRect)->x,(pRect)->y,(pRect)->width, \
  120.         (pRect)->height)
  121. /*
  122.  * Overlap BoxPtr and horizontal span
  123.  */
  124. #define SPN_OVERLAP(pCbox,y,x,w) BOX_OVERLAP((pCbox),(x),(y),(x)+(w),(y))
  125.  
  126. /*
  127.  * See if should check for cursor overlap. Drawable must be a window,
  128.  * be realized and on the same screen as the cursor. We don't try and do
  129.  * any region checking because it's slow and it leaves mouse droppings when
  130.  * doing a newiconify in uwm and you're moving the grid over a child of
  131.  * the RootWindow...
  132.  */
  133. #define Check(pDraw) \
  134.      ((((DrawablePtr)(pDraw))->type == DRAWABLE_WINDOW) && \
  135.      ((WindowPtr)(pDraw))->viewable && \
  136.      spriteCursorLoc ((((DrawablePtr)(pDraw))->pScreen), &cursorBox))
  137.  
  138. /*-
  139.  *-----------------------------------------------------------------------
  140.  * spriteSaveCursorBox --
  141.  *    Given an array of points, figure out the bounding box for the
  142.  *    series and remove the cursor if it overlaps that box.
  143.  *
  144.  * Results:
  145.  *
  146.  * Side Effects:
  147.  *
  148.  *-----------------------------------------------------------------------
  149.  */
  150. void
  151. spriteSaveCursorBox (xorg, yorg, mode, lw, pPts, nPts, pCursorBox)
  152.     register int          xorg;           /* X-Origin for points */
  153.     register int          yorg;           /* Y-Origin for points */
  154.     int                      mode;           /* CoordModeOrigin or
  155.                          * CoordModePrevious */
  156.     int                lw;            /* line width */
  157.     register DDXPointPtr    pPts;           /* Array of points */
  158.     int                      nPts;           /* Number of points */
  159.     register BoxPtr         pCursorBox;        /* Bounding box for cursor */
  160. {
  161.     register int          minx,           /* Lowest X coordinate of all pts*/
  162.                 miny,           /* Lowest Y coordinate */
  163.                 maxx,           /* Highest X coordinate */
  164.                 maxy;           /* Highest Y coordinate */
  165.  
  166.     minx = maxx = pPts->x + xorg;
  167.     miny = maxy = pPts->y + yorg;
  168.  
  169.     pPts++;
  170.     nPts--;
  171.  
  172.     if (mode == CoordModeOrigin) {
  173.     while (nPts--) {
  174.         minx = min(minx, pPts->x + xorg);
  175.         maxx = max(maxx, pPts->x + xorg);
  176.         miny = min(miny, pPts->y + yorg);
  177.         maxy = max(maxy, pPts->y + yorg);
  178.         pPts++;
  179.     }
  180.     } else {
  181.     xorg = minx;
  182.     yorg = miny;
  183.     while (nPts--) {
  184.         minx = min(minx, pPts->x + xorg);
  185.         maxx = max(maxx, pPts->x + xorg);
  186.         miny = min(miny, pPts->y + yorg);
  187.         maxy = max(maxy, pPts->y + yorg);
  188.         xorg += pPts->x;
  189.         yorg += pPts->y;
  190.         pPts++;
  191.     }
  192.     }
  193.     if (BOX_OVERLAP(pCursorBox,minx-lw,miny-lw,maxx+lw,maxy+lw)) {
  194.     spriteRemoveCursor();
  195.     }
  196. }
  197.                
  198. /*-
  199.  *-----------------------------------------------------------------------
  200.  * spriteFillSpans --
  201.  *    Remove the cursor if any of the spans overlaps the area covered
  202.  *    by the cursor. This assumes the points have been translated
  203.  *    already, though perhaps it shouldn't...
  204.  *
  205.  * Results:
  206.  *    None.
  207.  *
  208.  * Side Effects:
  209.  *
  210.  *-----------------------------------------------------------------------
  211.  */
  212. void
  213. spriteFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
  214.     DrawablePtr pDrawable;
  215.     GCPtr    pGC;
  216.     int        nInit;            /* number of spans to fill */
  217.     DDXPointPtr pptInit;        /* pointer to list of start points */
  218.     int        *pwidthInit;        /* pointer to list of n widths */
  219.     int     fSorted;
  220. {
  221.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  222.     BoxRec      cursorBox;
  223.  
  224.     if (Check(pDrawable)) {
  225.     register DDXPointPtr    pts;
  226.     register int        *widths;
  227.     register int        nPts;
  228.     
  229.     for (pts = pptInit, widths = pwidthInit, nPts = nInit;
  230.          nPts--;
  231.          pts++, widths++) {
  232.          if (SPN_OVERLAP(&cursorBox,pts->y,pts->x,*widths)) {
  233.              spriteRemoveCursor();
  234.              break;
  235.          }
  236.     }
  237.     }
  238.  
  239.     (* pShadowGC->FillSpans)(pDrawable, pShadowGC, nInit, pptInit,
  240.                  pwidthInit, fSorted);
  241. }
  242.  
  243. /*-
  244.  *-----------------------------------------------------------------------
  245.  * spriteSetSpans --
  246.  *    Remove the cursor if any of the horizontal segments overlaps
  247.  *    the area covered by the cursor. This also assumes the spans
  248.  *    have been translated from the window's coordinates to the
  249.  *    screen's.
  250.  * Results:
  251.  *    None.
  252.  *
  253.  * Side Effects:
  254.  *
  255.  *-----------------------------------------------------------------------
  256.  */
  257. void
  258. spriteSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted)
  259.     DrawablePtr        pDrawable;
  260.     GCPtr        pGC;
  261.     int            *psrc;
  262.     register DDXPointPtr ppt;
  263.     int            *pwidth;
  264.     int            nspans;
  265.     int            fSorted;
  266. {
  267.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  268.     BoxRec      cursorBox;
  269.  
  270.     if (Check(pDrawable)) {
  271.     register DDXPointPtr    pts;
  272.     register int        *widths;
  273.     register int        nPts;
  274.     
  275.     for (pts = ppt, widths = pwidth, nPts = nspans;
  276.          nPts--;
  277.          pts++, widths++) {
  278.          if (SPN_OVERLAP(&cursorBox,pts->y,pts->x,*widths)) {
  279.              spriteRemoveCursor();
  280.              break;
  281.          }
  282.     }
  283.     }
  284.  
  285.     (* pShadowGC->SetSpans) (pDrawable, pShadowGC, psrc, ppt, pwidth,
  286.                  nspans, fSorted);
  287. }
  288.  
  289. /*-
  290.  *-----------------------------------------------------------------------
  291.  * spriteGetSpans --
  292.  *    Remove the cursor if any of the desired spans overlaps it.
  293.  *
  294.  * Results:
  295.  *
  296.  * Side Effects:
  297.  *
  298.  *-----------------------------------------------------------------------
  299.  */
  300. unsigned int *
  301. spriteGetSpans(pDrawable, wMax, ppt, pwidth, nspans)
  302.     DrawablePtr        pDrawable;    /* drawable from which to get bits */
  303.     int            wMax;        /* largest value of all *pwidths */
  304.     register DDXPointPtr ppt;        /* points to start copying from */
  305.     int            *pwidth;    /* list of number of bits to copy */
  306.     int            nspans;        /* number of scanlines to copy */
  307. {
  308.     BoxRec      cursorBox;
  309.  
  310.     if (Check(pDrawable)) {
  311.     register DDXPointPtr    pts;
  312.     register int            *widths;
  313.     register int            nPts;
  314.     register int            xorg,
  315.                     yorg;
  316.     
  317.     xorg = ((WindowPtr)pDrawable)->absCorner.x;
  318.     yorg = ((WindowPtr)pDrawable)->absCorner.y;
  319.     
  320.     for (pts = ppt, widths = pwidth, nPts = nspans;
  321.          nPts--;
  322.          pts++, widths++) {
  323.          if (SPN_OVERLAP(&cursorBox,pts->y+yorg,
  324.                  pts->x+xorg,*widths)) {
  325.                      spriteRemoveCursor();
  326.                      break;
  327.          }
  328.     }
  329.     }
  330.  
  331.     /*
  332.      * XXX: Because we have no way to get at the GC used to call us,
  333.      * we must rely on the GetSpans vector never changing and stick it
  334.      * in the fbFd structure. Gross.
  335.      */
  336.     return (* spriteFbs[pDrawable->pScreen->myNum].GetSpans)(pDrawable, wMax,
  337.                               ppt, pwidth, nspans);
  338. }
  339.  
  340. /*-
  341.  *-----------------------------------------------------------------------
  342.  * spritePutImage --
  343.  *    Remove the cursor if it is in the way of the image to be
  344.  *    put down...
  345.  *
  346.  * Results:
  347.  *    None.
  348.  *
  349.  * Side Effects:
  350.  *
  351.  *-----------------------------------------------------------------------
  352.  */
  353. void
  354. spritePutImage(pDst, pGC, depth, x, y, w, h, leftPad, format, pBits)
  355.     DrawablePtr      pDst;
  356.     GCPtr         pGC;
  357.     int          depth;
  358.     int              x;
  359.     int              y;
  360.     int              w;
  361.     int              h;
  362.     int              format;
  363.     char          *pBits;
  364. {
  365.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  366.     BoxRec      cursorBox;
  367.  
  368.     if (Check(pDst)) {
  369.     register WindowPtr pWin = (WindowPtr)pDst;
  370.  
  371.     if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  372.             x,y,w,h)) {
  373.                 spriteRemoveCursor();
  374.     }
  375.     }
  376.  
  377.     (* pShadowGC->PutImage) (pDst, pShadowGC, depth, x, y, w, h,
  378.                  leftPad, format, pBits);
  379. }
  380.  
  381. /*-
  382.  *-----------------------------------------------------------------------
  383.  * spriteGetImage --
  384.  *    Remove the cursor if it overlaps the image to be gotten.
  385.  *
  386.  * Results:
  387.  *    None.
  388.  *
  389.  * Side Effects:
  390.  *
  391.  *-----------------------------------------------------------------------
  392.  */
  393. void
  394. spriteGetImage (pSrc, x, y, w, h, format, planeMask, pBits)
  395.     DrawablePtr      pSrc;
  396.     int              x;
  397.     int              y;
  398.     int              w;
  399.     int              h;
  400.     unsigned int  format;
  401.     unsigned int  planeMask;
  402.     int              *pBits;
  403. {
  404.     BoxRec      cursorBox;
  405.     if (Check(pSrc)) {
  406.     register WindowPtr    pWin = (WindowPtr)pSrc;
  407.     
  408.     if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  409.             x,y,w,h)) {
  410.                 spriteRemoveCursor();
  411.     }
  412.     }
  413.  
  414.     (* spriteFbs[pSrc->pScreen->myNum].GetImage) (pSrc, x, y, w, h, format,
  415.                            planeMask, pBits);
  416. }
  417.  
  418. /*-
  419.  *-----------------------------------------------------------------------
  420.  * spriteCopyArea --
  421.  *    Remove the cursor if it overlaps either the source or destination
  422.  *    drawables, then call the screen-specific CopyArea routine.
  423.  *
  424.  * Results:
  425.  *    None.
  426.  *
  427.  * Side Effects:
  428.  *
  429.  *-----------------------------------------------------------------------
  430.  */
  431. RegionPtr
  432. spriteCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty)
  433.     DrawablePtr      pSrc;
  434.     DrawablePtr      pDst;
  435.     GCPtr         pGC;
  436.     int              srcx;
  437.     int              srcy;
  438.     int              w;
  439.     int              h;
  440.     int              dstx;
  441.     int              dsty;
  442. {
  443.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  444.     BoxRec      cursorBox;
  445.     register WindowPtr    pWin;
  446.     int              out = FALSE;
  447.  
  448.     if (Check(pSrc)) {
  449.     pWin = (WindowPtr)pSrc;
  450.  
  451.     if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  452.             srcx, srcy, w, h)) {
  453.                 spriteRemoveCursor();
  454.                 out = TRUE;
  455.     }
  456.     }
  457.  
  458.     if (!out && Check(pDst)) {
  459.     pWin = (WindowPtr)pDst;
  460.         
  461.     if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  462.             dstx, dsty, w, h)) {
  463.                 spriteRemoveCursor();
  464.     }
  465.     }
  466.  
  467.     return (* pShadowGC->CopyArea) (pSrc, pDst, pShadowGC, srcx, srcy,
  468.                  w, h, dstx, dsty);
  469. }
  470.  
  471. /*-
  472.  *-----------------------------------------------------------------------
  473.  * spriteCopyPlane --
  474.  *    Remove the cursor as necessary and call the screen-specific
  475.  *    CopyPlane function.
  476.  *
  477.  * Results:
  478.  *    None.
  479.  *
  480.  * Side Effects:
  481.  *
  482.  *-----------------------------------------------------------------------
  483.  */
  484. RegionPtr
  485. spriteCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane)
  486.     DrawablePtr      pSrc;
  487.     DrawablePtr      pDst;
  488.     register GC   *pGC;
  489.     int           srcx,
  490.           srcy;
  491.     int           w,
  492.           h;
  493.     int           dstx,
  494.           dsty;
  495.     unsigned int  plane;
  496. {
  497.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  498.     BoxRec      cursorBox;
  499.     register WindowPtr    pWin;
  500.     int              out = FALSE;
  501.  
  502.     if (Check(pSrc)){
  503.     pWin = (WindowPtr)pSrc;
  504.  
  505.     if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  506.             srcx, srcy, w, h)) {
  507.                 spriteRemoveCursor();
  508.                 out = TRUE;
  509.     }
  510.     }
  511.  
  512.     if (!out && Check(pDst)) {
  513.     pWin = (WindowPtr)pDst;
  514.     
  515.     if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  516.             dstx, dsty, w, h)) {
  517.                 spriteRemoveCursor();
  518.     }
  519.     }
  520.  
  521.  
  522.     return (* pShadowGC->CopyPlane) (pSrc, pDst, pShadowGC, srcx, srcy, w, h,
  523.                   dstx, dsty, plane);
  524. }
  525.  
  526. /*-
  527.  *-----------------------------------------------------------------------
  528.  * spritePolyPoint --
  529.  *    See if any of the points lies within the area covered by the
  530.  *    cursor and remove the cursor if one does. Then put the points
  531.  *    down.
  532.  *
  533.  * Results:
  534.  *    None.
  535.  *
  536.  * Side Effects:
  537.  *
  538.  *-----------------------------------------------------------------------
  539.  */
  540. void
  541. spritePolyPoint (pDrawable, pGC, mode, npt, pptInit)
  542.     DrawablePtr pDrawable;
  543.     GCPtr    pGC;
  544.     int        mode;        /* Origin or Previous */
  545.     int        npt;
  546.     xPoint     *pptInit;
  547. {
  548.     register GCPtr     pShadowGC = (GCPtr) pGC->devPriv;
  549.     register xPoint     *pts;
  550.     register int      nPts;
  551.     register int      xorg;
  552.     register int      yorg;
  553.     BoxRec            cursorBox;
  554.  
  555.     if (Check(pDrawable)){
  556.     xorg = ((WindowPtr)pDrawable)->absCorner.x;
  557.     yorg = ((WindowPtr)pDrawable)->absCorner.y;
  558.     
  559.     if (mode == CoordModeOrigin) {
  560.         for (pts = pptInit, nPts = npt; nPts--; pts++) {
  561.         if (ORG_OVERLAP(&cursorBox,xorg,yorg,pts->x,pts->y,0,0)){
  562.             spriteRemoveCursor();
  563.             break;
  564.         }
  565.         }
  566.     } else {
  567.         for (pts = pptInit, nPts = npt; nPts--; pts++) {
  568.         if (ORG_OVERLAP(&cursorBox,xorg,yorg,pts->x,pts->y,0,0)){
  569.             spriteRemoveCursor();
  570.             break;
  571.         } else {
  572.             xorg += pts->x;
  573.             yorg += pts->y;
  574.         }
  575.         }
  576.     }
  577.     }
  578.  
  579.     (* pShadowGC->PolyPoint) (pDrawable, pShadowGC, mode, npt, pptInit);
  580. }
  581.  
  582. /*-
  583.  *-----------------------------------------------------------------------
  584.  * spritePolylines --
  585.  *    Find the bounding box of the lines and remove the cursor if
  586.  *    the box overlaps the area covered by the cursor. Then call
  587.  *    the screen's Polylines function to draw the lines themselves.
  588.  *
  589.  * Results:
  590.  *
  591.  * Side Effects:
  592.  *
  593.  *-----------------------------------------------------------------------
  594.  */
  595. void
  596. spritePolylines (pDrawable, pGC, mode, npt, pptInit)
  597.     DrawablePtr      pDrawable;
  598.     GCPtr         pGC;
  599.     int              mode;
  600.     int              npt;
  601.     DDXPointPtr      pptInit;
  602. {
  603.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  604.     BoxRec        cursorBox;
  605.  
  606.     if (Check(pDrawable)){
  607.     spriteSaveCursorBox(((WindowPtr)pDrawable)->absCorner.x,
  608.                 ((WindowPtr)pDrawable)->absCorner.y,
  609.                 mode,
  610.                 pShadowGC->lineWidth,
  611.                 pptInit,
  612.                 npt,
  613.                 &cursorBox);
  614.     }
  615.     (*pShadowGC->Polylines) (pDrawable, pShadowGC, mode, npt, pptInit);
  616. }
  617.  
  618. /*-
  619.  *-----------------------------------------------------------------------
  620.  * spritePolySegment --
  621.  *    Treat each segment as a box and remove the cursor if any box
  622.  *    overlaps the cursor's area. Then draw the segments. Note that
  623.  *    the endpoints of the segments are in no way guaranteed to be
  624.  *    in the right order, so we find the bounding box of the segment
  625.  *    in two comparisons and use that to figure things out.
  626.  *
  627.  * Results:
  628.  *    None.
  629.  *
  630.  * Side Effects:
  631.  *
  632.  *-----------------------------------------------------------------------
  633.  */
  634. void
  635. spritePolySegment(pDraw, pGC, nseg, pSegs)
  636.     DrawablePtr pDraw;
  637.     GCPtr     pGC;
  638.     int        nseg;
  639.     xSegment    *pSegs;
  640. {
  641.     register GCPtr     pShadowGC = (GCPtr) pGC->devPriv;
  642.     register xSegment    *pSeg;
  643.     register int      nSeg;
  644.     register int      xorg,
  645.             yorg;
  646.     BoxRec            cursorBox;
  647.     Bool              nuke = FALSE;
  648.  
  649.     if (Check(pDraw)){
  650.     xorg = ((WindowPtr)pDraw)->absCorner.x;
  651.     yorg = ((WindowPtr)pDraw)->absCorner.y;
  652.     
  653.     for (nSeg = nseg, pSeg = pSegs; nSeg--; pSeg++) {
  654.         if (pSeg->x1 < pSeg->x2) {
  655.         if (pSeg->y1 < pSeg->y2) {
  656.             nuke = BOX_OVERLAP(&cursorBox,
  657.                        pSeg->x1+xorg,pSeg->y1+yorg,
  658.                        pSeg->x2+xorg,pSeg->y2+yorg);
  659.         } else {
  660.             nuke = BOX_OVERLAP(&cursorBox,
  661.                        pSeg->x1+xorg,pSeg->y2+yorg,
  662.                        pSeg->x2+xorg,pSeg->y1+yorg);
  663.         }
  664.         } else if (pSeg->y1 < pSeg->y2) {
  665.         nuke = BOX_OVERLAP(&cursorBox,
  666.                    pSeg->x2+xorg,pSeg->y1+yorg,
  667.                    pSeg->x1+xorg,pSeg->y2+yorg);
  668.         } else {
  669.         nuke = BOX_OVERLAP(&cursorBox,
  670.                    pSeg->x2+xorg,pSeg->y2+yorg,
  671.                    pSeg->x1+xorg,pSeg->y1+yorg);
  672.         }
  673.         if (nuke) {
  674.         spriteRemoveCursor();
  675.         break;
  676.         }
  677.     }
  678.     }
  679.  
  680.     (* pShadowGC->PolySegment) (pDraw, pShadowGC, nseg, pSegs);
  681. }
  682.  
  683. /*-
  684.  *-----------------------------------------------------------------------
  685.  * spritePolyRectangle --
  686.  *    Remove the cursor if it overlaps any of the rectangles to be
  687.  *    drawn, then draw them.
  688.  *
  689.  * Results:
  690.  *    None
  691.  *
  692.  * Side Effects:
  693.  *
  694.  *-----------------------------------------------------------------------
  695.  */
  696. void
  697. spritePolyRectangle(pDraw, pGC, nrects, pRects)
  698.     DrawablePtr    pDraw;
  699.     GCPtr    pGC;
  700.     int        nrects;
  701.     xRectangle    *pRects;
  702. {
  703.     register GCPtr     pShadowGC = (GCPtr) pGC->devPriv;
  704.     register xRectangle    *pRect;
  705.     register int      nRect;
  706.     register int      xorg,
  707.             yorg;
  708.     BoxRec            cursorBox;
  709.  
  710.     if (Check(pDraw)) {
  711.     xorg = ((WindowPtr)pDraw)->absCorner.x;
  712.     yorg = ((WindowPtr)pDraw)->absCorner.y;
  713.     
  714.     for (nRect = nrects, pRect = pRects; nRect--; pRect++) {
  715.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pRect)){
  716.         spriteRemoveCursor();
  717.         break;
  718.         }
  719.     }
  720.     }
  721.  
  722.     (* pShadowGC->PolyRectangle) (pDraw, pShadowGC, nrects, pRects);
  723. }
  724.  
  725. /*-
  726.  *-----------------------------------------------------------------------
  727.  * spritePolyArc --
  728.  *    Using the bounding rectangle of each arc, remove the cursor
  729.  *    if it overlaps any arc, then draw all the arcs.
  730.  *
  731.  * Results:
  732.  *
  733.  * Side Effects:
  734.  *
  735.  *-----------------------------------------------------------------------
  736.  */
  737. void
  738. spritePolyArc(pDraw, pGC, narcs, parcs)
  739.     DrawablePtr    pDraw;
  740.     GCPtr    pGC;
  741.     int        narcs;
  742.     xArc    *parcs;
  743. {
  744.     register GCPtr     pShadowGC = (GCPtr) pGC->devPriv;
  745.     register xArc    *pArc;
  746.     register int      nArc;
  747.     register int      xorg,
  748.             yorg;
  749.     BoxRec            cursorBox;
  750.  
  751.     if (Check(pDraw)) {
  752.     xorg = ((WindowPtr)pDraw)->absCorner.x;
  753.     yorg = ((WindowPtr)pDraw)->absCorner.y;
  754.     
  755.     for (nArc = narcs, pArc = parcs; nArc--; pArc++) {
  756.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pArc)){
  757.         spriteRemoveCursor();
  758.         break;
  759.         }
  760.     }
  761.     }
  762.  
  763.     (* pShadowGC->PolyArc) (pDraw, pShadowGC, narcs, parcs);
  764. }
  765.  
  766. /*-
  767.  *-----------------------------------------------------------------------
  768.  * spriteFillPolygon --
  769.  *    Find the bounding box of the polygon to fill and remove the
  770.  *    cursor if it overlaps this box...
  771.  *
  772.  * Results:
  773.  *    None.
  774.  *
  775.  * Side Effects:
  776.  *
  777.  *-----------------------------------------------------------------------
  778.  */
  779. void
  780. spriteFillPolygon(pDraw, pGC, shape, mode, count, pPts)
  781.     DrawablePtr        pDraw;
  782.     register GCPtr    pGC;
  783.     int            shape, mode;
  784.     register int    count;
  785.     DDXPointPtr        pPts;
  786. {
  787.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  788.     BoxRec            cursorBox;
  789.  
  790.     if (Check(pDraw)) {
  791.     spriteSaveCursorBox(((WindowPtr)pDraw)->absCorner.x,
  792.                 ((WindowPtr)pDraw)->absCorner.y,
  793.                 mode,
  794.                 0,
  795.                 pPts,
  796.                 count,
  797.                 &cursorBox);
  798.     }
  799.  
  800.     (* pShadowGC->FillPolygon) (pDraw, pShadowGC, shape, mode, count, pPts);
  801. }
  802.  
  803. /*-
  804.  *-----------------------------------------------------------------------
  805.  * spritePolyFillRect --
  806.  *    Remove the cursor if it overlaps any of the filled rectangles
  807.  *    to be drawn by the output routines.
  808.  *
  809.  * Results:
  810.  *    None.
  811.  *
  812.  * Side Effects:
  813.  *
  814.  *-----------------------------------------------------------------------
  815.  */
  816. void
  817. spritePolyFillRect(pDrawable, pGC, nrectFill, prectInit)
  818.     DrawablePtr pDrawable;
  819.     GCPtr    pGC;
  820.     int        nrectFill;     /* number of rectangles to fill */
  821.     xRectangle    *prectInit;      /* Pointer to first rectangle to fill */
  822. {
  823.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  824.     register xRectangle    *pRect;
  825.     register int      nRect;
  826.     register int      xorg,
  827.             yorg;
  828.     BoxRec            cursorBox;
  829.  
  830.     if (Check(pDrawable)) {
  831.     xorg = ((WindowPtr)pDrawable)->absCorner.x;
  832.     yorg = ((WindowPtr)pDrawable)->absCorner.y;
  833.     
  834.     for (nRect = nrectFill, pRect = prectInit; nRect--; pRect++) {
  835.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pRect)){
  836.         spriteRemoveCursor();
  837.         break;
  838.         }
  839.     }
  840.     }
  841.  
  842.     (* pShadowGC->PolyFillRect) (pDrawable, pShadowGC, nrectFill, prectInit);
  843. }
  844.  
  845. /*-
  846.  *-----------------------------------------------------------------------
  847.  * spritePolyFillArc --
  848.  *    See if the cursor overlaps any of the bounding boxes for the
  849.  *    filled arc and remove it if it does.
  850.  *
  851.  * Results:
  852.  *    None.
  853.  *
  854.  * Side Effects:
  855.  *
  856.  *-----------------------------------------------------------------------
  857.  */
  858. void
  859. spritePolyFillArc(pDraw, pGC, narcs, parcs)
  860.     DrawablePtr    pDraw;
  861.     GCPtr    pGC;
  862.     int        narcs;
  863.     xArc    *parcs;
  864. {
  865.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  866.     register xArc    *pArc;
  867.     register int      nArc;
  868.     register int      xorg,
  869.             yorg;
  870.     BoxRec            cursorBox;
  871.  
  872.     if (Check(pDraw)) {
  873.     xorg = ((WindowPtr)pDraw)->absCorner.x;
  874.     yorg = ((WindowPtr)pDraw)->absCorner.y;
  875.     
  876.     for (nArc = narcs, pArc = parcs; nArc--; pArc++) {
  877.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pArc)){
  878.         spriteRemoveCursor();
  879.         break;
  880.         }
  881.     }
  882.     }
  883.  
  884.     (* pShadowGC->PolyFillArc) (pDraw, pShadowGC, narcs, parcs);
  885. }
  886.  
  887. /*-
  888.  *-----------------------------------------------------------------------
  889.  * spriteText --
  890.  *    Find the extent of a text operation and remove the cursor if they
  891.  *    overlap. pDraw is assumed to be a window.
  892.  *
  893.  * Results:
  894.  *
  895.  * Side Effects:
  896.  *
  897.  *-----------------------------------------------------------------------
  898.  */
  899. int
  900. spriteText(pDraw, pGC, x, y, count, chars, fontEncoding, drawFunc)
  901.     DrawablePtr   pDraw;
  902.     GCPtr      pGC;
  903.     int          x,
  904.           y;
  905.     int          count;
  906.     char       *chars;
  907.     FontEncoding  fontEncoding;
  908.     void          (*drawFunc)();
  909. {
  910.     CharInfoPtr   *charinfo;
  911.     unsigned int  n,
  912.           w;
  913.     register int  xorg,
  914.           yorg;
  915.     ExtentInfoRec extents;
  916.     BoxRec        cursorBox;
  917.  
  918.     charinfo = (CharInfoPtr *)ALLOCATE_LOCAL (count * sizeof(CharInfoPtr));
  919.     if (charinfo == (CharInfoPtr *)NULL) {
  920.     return x;
  921.     }
  922.  
  923.     GetGlyphs(pGC->font, count, chars, fontEncoding, &n, charinfo);
  924.  
  925.     if (n != 0) {
  926.     /*
  927.      * Because we need to know the width of the operation in order to
  928.      * return the new offset, we always have to do this. Let's hope
  929.      * QueryGlyphExtents has been optimized...
  930.      */
  931.     QueryGlyphExtents(pGC->font, charinfo, n, &extents);
  932.     w = extents.overallWidth;
  933.     if (spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  934.         xorg = ((WindowPtr)pDraw)->absCorner.x;
  935.         yorg = ((WindowPtr)pDraw)->absCorner.y;
  936.     
  937.         if (BOX_OVERLAP(&cursorBox,
  938.                 x + xorg + extents.overallLeft,
  939.                 y + yorg - extents.overallAscent,
  940.                 x + xorg + extents.overallRight,
  941.                 y + yorg + extents.overallDescent)) {
  942.                 spriteRemoveCursor();
  943.         }
  944.     }
  945.         (* drawFunc)(pDraw, pGC, x, y, n, charinfo, pGC->font->pGlyphs);
  946.     } else {
  947.     w = 0;
  948.     }
  949.     
  950.     DEALLOCATE_LOCAL(charinfo);
  951.     return x+w;
  952. }
  953.  
  954. /*-
  955.  *-----------------------------------------------------------------------
  956.  * spritePolyText8 --
  957.  *
  958.  * Results:
  959.  *
  960.  * Side Effects:
  961.  *
  962.  *-----------------------------------------------------------------------
  963.  */
  964. int
  965. spritePolyText8(pDraw, pGC, x, y, count, chars)
  966.     DrawablePtr pDraw;
  967.     GCPtr    pGC;
  968.     int        x, y;
  969.     int     count;
  970.     char    *chars;
  971. {
  972.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  973.  
  974.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->viewable) {
  975.     return spriteText (pDraw, pShadowGC, x, y, count, chars, Linear8Bit,
  976.             pShadowGC->PolyGlyphBlt);
  977.     } else {
  978.     return (* pShadowGC->PolyText8)(pDraw, pShadowGC, x, y, count, chars);
  979.     }
  980. }
  981.  
  982. /*-
  983.  *-----------------------------------------------------------------------
  984.  * spritePolyText16 --
  985.  *
  986.  * Results:
  987.  *
  988.  * Side Effects:
  989.  *
  990.  *-----------------------------------------------------------------------
  991.  */
  992. int
  993. spritePolyText16(pDraw, pGC, x, y, count, chars)
  994.     DrawablePtr pDraw;
  995.     GCPtr    pGC;
  996.     int        x, y;
  997.     int        count;
  998.     unsigned short *chars;
  999. {
  1000.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  1001.  
  1002.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->viewable) {
  1003.     return spriteText (pDraw, pShadowGC, x, y, count, chars,
  1004.             (pShadowGC->font->pFI->lastRow == 0 ?
  1005.              Linear16Bit : TwoD16Bit),
  1006.             pShadowGC->PolyGlyphBlt);
  1007.     } else {
  1008.     return (* pShadowGC->PolyText16) (pDraw, pShadowGC, x, y,
  1009.                       count, chars);
  1010.     }
  1011. }
  1012.  
  1013. /*-
  1014.  *-----------------------------------------------------------------------
  1015.  * spriteImageText8 --
  1016.  *
  1017.  * Results:
  1018.  *
  1019.  * Side Effects:
  1020.  *
  1021.  *-----------------------------------------------------------------------
  1022.  */
  1023. void
  1024. spriteImageText8(pDraw, pGC, x, y, count, chars)
  1025.     DrawablePtr pDraw;
  1026.     GCPtr    pGC;
  1027.     int        x, y;
  1028.     int        count;
  1029.     char    *chars;
  1030. {
  1031.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  1032.  
  1033.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->viewable) {
  1034.     (void) spriteText (pDraw, pShadowGC, x, y, count, chars,
  1035.             Linear8Bit, pShadowGC->ImageGlyphBlt);
  1036.     } else {
  1037.     (* pShadowGC->ImageText8) (pDraw, pShadowGC, x, y, count, chars);
  1038.     }
  1039. }
  1040.  
  1041. /*-
  1042.  *-----------------------------------------------------------------------
  1043.  * spriteImageText16 --
  1044.  *
  1045.  * Results:
  1046.  *
  1047.  * Side Effects:
  1048.  *
  1049.  *-----------------------------------------------------------------------
  1050.  */
  1051. void
  1052. spriteImageText16(pDraw, pGC, x, y, count, chars)
  1053.     DrawablePtr pDraw;
  1054.     GCPtr    pGC;
  1055.     int        x, y;
  1056.     int        count;
  1057.     unsigned short *chars;
  1058. {
  1059.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  1060.  
  1061.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->viewable) {
  1062.     (void) spriteText (pDraw, pShadowGC, x, y, count, chars,
  1063.                (pShadowGC->font->pFI->lastRow == 0 ?
  1064.                 Linear16Bit : TwoD16Bit),
  1065.                pShadowGC->ImageGlyphBlt);
  1066.     } else {
  1067.     (* pShadowGC->ImageText16) (pDraw, pShadowGC, x, y, count, chars);
  1068.     }
  1069. }
  1070.  
  1071. /*-
  1072.  *-----------------------------------------------------------------------
  1073.  * spriteImageGlyphBlt --
  1074.  *
  1075.  * Results:
  1076.  *
  1077.  * Side Effects:
  1078.  *
  1079.  *-----------------------------------------------------------------------
  1080.  */
  1081. void
  1082. spriteImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
  1083.     DrawablePtr pDrawable;
  1084.     GC         *pGC;
  1085.     int     x, y;
  1086.     unsigned int nglyph;
  1087.     CharInfoPtr *ppci;        /* array of character info */
  1088.     pointer     pglyphBase;    /* start of array of glyphs */
  1089. {
  1090.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  1091.     BoxRec            cursorBox;
  1092.     ExtentInfoRec     extents;
  1093.     register int      xorg,
  1094.             yorg;
  1095.  
  1096.     if (Check(pDrawable)) {
  1097.     QueryGlyphExtents (pGC->font, ppci, nglyph, &extents);
  1098.     xorg = ((WindowPtr)pDrawable)->absCorner.x + x;
  1099.     yorg = ((WindowPtr)pDrawable)->absCorner.y + y;
  1100.     if (BOX_OVERLAP(&cursorBox,xorg+extents.overallLeft,
  1101.             yorg+extents.overallAscent,
  1102.             xorg+extents.overallRight,
  1103.             yorg+extents.overallDescent)) {
  1104.                 spriteRemoveCursor();
  1105.     }
  1106.     }
  1107.  
  1108.     (* pShadowGC->ImageGlyphBlt) (pDrawable, pShadowGC, x, y, nglyph,
  1109.                   ppci, pglyphBase);
  1110. }
  1111.  
  1112. /*-
  1113.  *-----------------------------------------------------------------------
  1114.  * spritePolyGlyphBlt --
  1115.  *
  1116.  * Results:
  1117.  *
  1118.  * Side Effects:
  1119.  *
  1120.  *-----------------------------------------------------------------------
  1121.  */
  1122. void
  1123. spritePolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
  1124.     DrawablePtr pDrawable;
  1125.     GCPtr    pGC;
  1126.     int     x, y;
  1127.     unsigned int nglyph;
  1128.     CharInfoPtr *ppci;        /* array of character info */
  1129.     char     *pglyphBase;    /* start of array of glyphs */
  1130. {
  1131.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  1132.     BoxRec            cursorBox;
  1133.     ExtentInfoRec     extents;
  1134.     register int      xorg,
  1135.             yorg;
  1136.  
  1137.     if (Check(pDrawable)) {
  1138.     QueryGlyphExtents (pGC->font, ppci, nglyph, &extents);
  1139.     xorg = ((WindowPtr)pDrawable)->absCorner.x + x;
  1140.     yorg = ((WindowPtr)pDrawable)->absCorner.y + y;
  1141.     if (BOX_OVERLAP(&cursorBox,xorg+extents.overallLeft,
  1142.             yorg+extents.overallAscent,
  1143.             xorg+extents.overallRight,
  1144.             yorg+extents.overallDescent)){
  1145.                 spriteRemoveCursor();
  1146.     }
  1147.     }
  1148.  
  1149.     (* pShadowGC->PolyGlyphBlt) (pDrawable, pShadowGC, x, y,
  1150.                 nglyph, ppci, pglyphBase);
  1151. }
  1152.  
  1153. /*-
  1154.  *-----------------------------------------------------------------------
  1155.  * spritePushPixels --
  1156.  *
  1157.  * Results:
  1158.  *
  1159.  * Side Effects:
  1160.  *
  1161.  *-----------------------------------------------------------------------
  1162.  */
  1163. void
  1164. spritePushPixels(pGC, pBitMap, pDst, w, h, x, y)
  1165.     GCPtr    pGC;
  1166.     PixmapPtr    pBitMap;
  1167.     DrawablePtr pDst;
  1168.     int        w, h, x, y;
  1169. {
  1170.  
  1171.     register GCPtr    pShadowGC = (GCPtr) pGC->devPriv;
  1172.     BoxRec            cursorBox;
  1173.     register int      xorg,
  1174.             yorg;
  1175.  
  1176.     if (Check(pDst)) {
  1177.     xorg = ((WindowPtr)pDst)->absCorner.x + x;
  1178.     yorg = ((WindowPtr)pDst)->absCorner.y + y;
  1179.     
  1180.     if (BOX_OVERLAP(&cursorBox,xorg,yorg,xorg+w,yorg+h)){
  1181.         spriteRemoveCursor();
  1182.     }
  1183.     }
  1184.  
  1185.     (* pShadowGC->PushPixels) (pShadowGC, pBitMap, pDst, w, h, x, y);
  1186. }
  1187.  
  1188. /*-
  1189.  *-----------------------------------------------------------------------
  1190.  * spriteLineHelper --
  1191.  *
  1192.  * Results:
  1193.  *
  1194.  * Side Effects:
  1195.  *
  1196.  *-----------------------------------------------------------------------
  1197.  */
  1198. void
  1199. spriteLineHelper (pDraw, pGC, caps, npt, pPts, xOrg, yOrg)
  1200.     DrawablePtr pDraw;
  1201.     GCPtr    pGC;
  1202.     int        caps;
  1203.     int        npt;
  1204.     SppPointPtr pPts;
  1205.     int        xOrg, yOrg;
  1206. {
  1207.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  1208.  
  1209.     (* pShadowGC->LineHelper) (pDraw, pGC, caps, npt, pPts, xOrg, yOrg);
  1210. }
  1211.  
  1212. /*-
  1213.  *-----------------------------------------------------------------------
  1214.  * spriteChangeClip --
  1215.  *    Front end for changing the clip in the GC. Just passes the command
  1216.  *    on through the shadow GC.
  1217.  *
  1218.  * Results:
  1219.  *    None.
  1220.  *
  1221.  * Side Effects:
  1222.  *    ???
  1223.  *
  1224.  *-----------------------------------------------------------------------
  1225.  */
  1226. void
  1227. spriteChangeClip (pGC, type, pValue, numRects)
  1228.     GCPtr         pGC;
  1229.     int              type;
  1230.     pointer       pValue;
  1231.     int              numRects;
  1232. {
  1233.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  1234.  
  1235.     (* pShadowGC->ChangeClip) (pShadowGC, type, pValue, numRects);
  1236.     /*
  1237.      *    Now copy the clip info back from the shadow to the real
  1238.      *    GC so that if we use it as the source for a CopyGC,
  1239.      *    the clip info will get copied along with everything
  1240.      *    else.
  1241.      */
  1242.     pGC->clientClip = pShadowGC->clientClip;
  1243.     pGC->clientClipType = pShadowGC->clientClipType;
  1244. }
  1245.  
  1246. /*-
  1247.  *-----------------------------------------------------------------------
  1248.  * spriteDestroyClip --
  1249.  *    Ditto for destroying the clipping region of the GC.
  1250.  *
  1251.  * Results:
  1252.  *    None.
  1253.  *
  1254.  * Side Effects:
  1255.  *    ???
  1256.  *
  1257.  *-----------------------------------------------------------------------
  1258.  */
  1259. void
  1260. spriteDestroyClip (pGC)
  1261.     GCPtr   pGC;
  1262. {
  1263.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  1264.  
  1265.     (* pShadowGC->DestroyClip) (pShadowGC);
  1266.     /* presumably this is NULL,  or junk,  or something.... */
  1267.     pGC->clientClip = pShadowGC->clientClip;
  1268.     pGC->clientClipType = pShadowGC->clientClipType;
  1269.  
  1270. }
  1271.  
  1272. /*-
  1273.  *-----------------------------------------------------------------------
  1274.  * spriteCopyClip --
  1275.  *    Ditto for copying the clipping region of the GC. Note that it
  1276.  *    is possible for us to be called to copy the clip from a shadow
  1277.  *    GC to a top-level (one of our) GC (the backing-store scheme in
  1278.  *    MI will do such a thing), so we must be careful.
  1279.  *
  1280.  * Results:
  1281.  *    None.
  1282.  *
  1283.  * Side Effects:
  1284.  *    ???
  1285.  *
  1286.  *-----------------------------------------------------------------------
  1287.  */
  1288. void
  1289. spriteCopyClip (pgcDst, pgcSrc)
  1290.     GCPtr   pgcDst, pgcSrc;
  1291. {
  1292.     register GCPtr pShadowSrcGC = (GCPtr) pgcSrc->devPriv;
  1293.     register GCPtr pShadowDstGC = (GCPtr) pgcDst->devPriv;
  1294.  
  1295.     if ((void (*)())pgcSrc->FillSpans != (void (*)())spriteFillSpans) {
  1296.     /*
  1297.      * The source is a shadow GC in its own right, so don't try to
  1298.      * reference through the devPriv field...
  1299.      */
  1300.     pShadowSrcGC = pgcSrc;
  1301.     }
  1302.     
  1303.     (* pShadowDstGC->CopyClip) (pShadowDstGC, pShadowSrcGC);
  1304.     pgcDst->clientClip = pShadowDstGC->clientClip;
  1305.     pgcDst->clientClipType = pShadowDstGC->clientClipType;
  1306. }
  1307.  
  1308. /*-
  1309.  *-----------------------------------------------------------------------
  1310.  * spriteDestroyGC --
  1311.  *    Function called when a GC is being freed. Simply unlinks and frees
  1312.  *    the GCInterest structure.
  1313.  *
  1314.  * Results:
  1315.  *    None.
  1316.  *
  1317.  * Side Effects:
  1318.  *    The GCInterest structure is removed from the chain but its own
  1319.  *    links are untouched (so FreeGC has something to follow...)
  1320.  *
  1321.  *-----------------------------------------------------------------------
  1322.  */
  1323. void
  1324. spriteDestroyGC (pGC, pGCI)
  1325.     GCPtr       pGC;    /* GC pGCI is attached to */
  1326.     GCInterestPtr  pGCI;    /* GCInterest being destroyed */
  1327. {
  1328.     if (pGC->devPriv)
  1329.     FreeGC ((GCPtr)pGC->devPriv);
  1330.     Xfree (pGCI);
  1331. }
  1332.  
  1333. /*-
  1334.  *-----------------------------------------------------------------------
  1335.  * spriteValidateGC --
  1336.  *    Called when a GC is about to be used for drawing. Copies all
  1337.  *    changes from the GC to its shadow and validates the shadow.
  1338.  *
  1339.  * Results:
  1340.  *    TRUE, for no readily apparent reason.
  1341.  *
  1342.  * Side Effects:
  1343.  *    Vectors in the shadow GC will likely be changed.
  1344.  *
  1345.  *-----------------------------------------------------------------------
  1346.  */
  1347. /*ARGSUSED*/
  1348. static void
  1349. spriteValidateGC (pGC, pGCI, changes, pDrawable)
  1350.     GCPtr      pGC;
  1351.     GCInterestPtr pGCI;
  1352.     Mask      changes;
  1353.     DrawablePtr      pDrawable;
  1354. {
  1355.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  1356.  
  1357.     if ( pGC->depth != pDrawable->depth )
  1358.     FatalError( "spriteValidateGC: depth mismatch.\n" );
  1359. /*
  1360.  *  spriteValidateGC copies the GC to the shadow.  Alas,
  1361.  *  spriteChangeClip has stored the new clip in the shadow,
  1362.  *  where it will be overwritten,  unless we pretend
  1363.  *  that the clip hasn't changed.
  1364.  */
  1365.     changes &= ~GCClipMask;
  1366.  
  1367.     CopyGC (pGC, pShadowGC, changes);
  1368.     pShadowGC->serialNumber = pGC->serialNumber;
  1369.     ValidateGC (pDrawable, pShadowGC);
  1370. }
  1371.     
  1372. /*-
  1373.  *-----------------------------------------------------------------------
  1374.  * spriteCopyGC --
  1375.  *    Called when a GC with its shadow is the destination of a copy.
  1376.  *    Calls CopyGC to transfer the changes to the shadow GC as well.
  1377.  *    Should not be used for the CopyGCSource since we like to copy from
  1378.  *    the real GC to the shadow using CopyGC...
  1379.  *
  1380.  * Results:
  1381.  *    None.
  1382.  *
  1383.  * Side Effects:
  1384.  *    Any changes in the real GC are copied to the shadow.
  1385.  *
  1386.  *-----------------------------------------------------------------------
  1387.  */
  1388. /*ARGSUSED*/
  1389. void
  1390. spriteCopyGC (pGCDst, pGCI, changes, pGCSrc)
  1391.     GCPtr         pGCDst;
  1392.     GCInterestPtr pGCI;
  1393.     int          changes;
  1394.     GCPtr         pGCSrc;
  1395. {
  1396.     CopyGC (pGCDst, (GCPtr) pGCDst->devPriv, pGCDst->stateChanges|changes);
  1397. }
  1398.  
  1399.  
  1400. /*
  1401.  * Array of functions to replace the functions in the GC.
  1402.  * Caveat: Depends on the ordering of functions in the GC structure.
  1403.  */
  1404. static void (* spriteGCFuncs[]) () = {
  1405.     spriteFillSpans,
  1406.     spriteSetSpans,
  1407.  
  1408.     spritePutImage,
  1409.     spriteCopyArea,
  1410.     spriteCopyPlane,
  1411.     spritePolyPoint,
  1412.     spritePolylines,
  1413.     spritePolySegment,
  1414.     spritePolyRectangle,
  1415.     spritePolyArc,
  1416.     spriteFillPolygon,
  1417.     spritePolyFillRect,
  1418.     spritePolyFillArc,
  1419.     (void(*)())spritePolyText8,
  1420.     (void(*)())spritePolyText16,
  1421.     spriteImageText8,
  1422.     spriteImageText16,
  1423.     spriteImageGlyphBlt,
  1424.     spritePolyGlyphBlt,
  1425.     spritePushPixels,
  1426.     spriteLineHelper,
  1427.     spriteChangeClip,
  1428.     spriteDestroyClip,
  1429.     spriteCopyClip,
  1430. };
  1431.  
  1432. /*-
  1433.  *-----------------------------------------------------------------------
  1434.  * spriteCreatePrivGC --
  1435.  *    Create a GC private to the Sun DDX code. Such a GC is unhampered
  1436.  *    by any shadow GC and should only be used by functions which know
  1437.  *    what they are doing. This substitutes the old CreateGC function
  1438.  *    in the drawable's screen's vector and calls the DIX CreateGC
  1439.  *    function. Once done, it restores the CreateGC vector to its
  1440.  *    proper state and returns the GCPtr CreateGC gave back.
  1441.  *
  1442.  * Results:
  1443.  *    A pointer to the new GC.
  1444.  *
  1445.  * Side Effects:
  1446.  *    The GC's graphicsExposures field is set FALSE.
  1447.  *
  1448.  *-----------------------------------------------------------------------
  1449.  */
  1450. GCPtr
  1451. spriteCreatePrivGC(pDrawable, mask, pval, pStatus)
  1452.     DrawablePtr      pDrawable;
  1453.     BITS32      mask;
  1454.     long      *pval;
  1455.     BITS32      *pStatus;
  1456. {
  1457.     fbFd          *fb;
  1458.     GCPtr         pGC;
  1459.     BITS32        ge = FALSE;
  1460.  
  1461.     fb = &spriteFbs[pDrawable->pScreen->myNum];
  1462.     pDrawable->pScreen->CreateGC = fb->CreateGC;
  1463.  
  1464.     pGC = GetScratchGC (pDrawable->depth, pDrawable->pScreen);
  1465.     ChangeGC (pGC, mask, pval);
  1466.     ChangeGC (pGC, GCGraphicsExposures, &ge);
  1467.  
  1468.     pDrawable->pScreen->CreateGC = spriteCreateGC;
  1469.  
  1470.     return pGC;
  1471. }
  1472.  
  1473. /*-
  1474.  *-----------------------------------------------------------------------
  1475.  * spriteCreateGC --
  1476.  *    This function is used to get our own validation hooks into each
  1477.  *    GC to preserve the cursor. It calls the regular creation routine
  1478.  *    for the screen and then, if that was successful, tacks another
  1479.  *    GCInterest structure onto the GC *after* the one placed on by
  1480.  *    the screen-specific CreateGC...
  1481.  *
  1482.  * Results:
  1483.  *    TRUE if created ok. FALSE otherwise.
  1484.  *
  1485.  * Side Effects:
  1486.  *    A GCInterest structure is stuck on the end of the GC's list.
  1487.  *
  1488.  *-----------------------------------------------------------------------
  1489.  */
  1490. Bool
  1491. spriteCreateGC (pGC)
  1492.     GCPtr    pGC;    /* The GC to play with */
  1493. {
  1494.     GCInterestPtr    pGCI;
  1495.     register GCPtr    pShadowGC;
  1496.     int            i;
  1497.     
  1498.     if ((*spriteFbs[pGC->pScreen->myNum].CreateGC) (pGC)) {
  1499.     
  1500.     if (pGC->depth != pGC->pScreen->rootDepth) {
  1501.         /*
  1502.          * This GC will never be used for drawing on the screen so no
  1503.          * shadow needed.
  1504.          */
  1505.         return (TRUE);
  1506.     }
  1507.     pShadowGC = (GCPtr) Xalloc (sizeof (GC));
  1508.     if (pShadowGC == (GCPtr)NULL) {
  1509.         return FALSE;
  1510.     }
  1511.     
  1512.     *pShadowGC = *pGC;
  1513.     pGC->devPriv = (pointer)pShadowGC;
  1514.     bcopy (spriteGCFuncs, &pGC->FillSpans, sizeof (spriteGCFuncs));
  1515.     
  1516.     pGCI = (GCInterestPtr) Xalloc (sizeof (GCInterestRec));
  1517.     if (!pGCI) {
  1518.         return FALSE;
  1519.     }
  1520.  
  1521.     /*
  1522.      * Any structure being shared between these two GCs must have its
  1523.      * reference count incremented. This includes:
  1524.      *  font, tile, stipple.
  1525.      * Anything which doesn't have a reference count must be duplicated:
  1526.      *  dash
  1527.      * 
  1528.      */
  1529.     if (pGC->font) {
  1530.         pGC->font->refcnt++;
  1531.     }
  1532.     if (pGC->tile) {
  1533.         pGC->tile->refcnt++;
  1534.     }
  1535.     if (pGC->stipple) {
  1536.         pGC->stipple->refcnt++;
  1537.     }
  1538.  
  1539.     pShadowGC->dash = (unsigned char *)
  1540.         Xalloc(pGC->numInDashList * sizeof(unsigned char));
  1541.     for (i=0; i<pGC->numInDashList; i++) {
  1542.         pShadowGC->dash[i] = pGC->dash[i];
  1543.     }
  1544.  
  1545.     pGC->pNextGCInterest = pGCI;
  1546.     pGC->pLastGCInterest = pGCI;
  1547.     pGCI->pNextGCInterest = (GCInterestPtr) &pGC->pNextGCInterest;
  1548.     pGCI->pLastGCInterest = (GCInterestPtr) &pGC->pNextGCInterest;
  1549.     pGCI->length = sizeof(GCInterestRec);
  1550.     pGCI->owner = 0;                /* server owns this */
  1551.     pGCI->ValInterestMask = ~0;         /* interested in everything */
  1552.     pGCI->ValidateGC = spriteValidateGC;
  1553.     pGCI->ChangeInterestMask = 0;         /* interested in nothing */
  1554.     pGCI->ChangeGC = (int (*)()) NULL;
  1555.     pGCI->CopyGCSource = (void (*)())NULL;
  1556.     pGCI->CopyGCDest = spriteCopyGC;
  1557.     pGCI->DestroyGC = spriteDestroyGC;
  1558.     
  1559.  
  1560.     /*
  1561.      * Because of this weird way of handling the GCInterest lists,
  1562.      * we need to modify the output library's GCInterest structure to
  1563.      * point to the pNextGCInterest field of the shadow GC...
  1564.      */
  1565.     pGCI = pShadowGC->pNextGCInterest;
  1566.     pGCI->pLastGCInterest = pGCI->pNextGCInterest =
  1567.         (GCInterestPtr) &pShadowGC->pNextGCInterest;
  1568.  
  1569.     return TRUE;
  1570.     } else {
  1571.     return FALSE;
  1572.     }
  1573. }
  1574. @
  1575.  
  1576.  
  1577. 1.8
  1578. log
  1579. @*** empty log message ***
  1580. @
  1581. text
  1582. @d20 1
  1583. a20 1
  1584.     "$Header: spriteGC.c,v 1.7 88/02/19 17:42:25 deboor Exp $ SPRITE (Berkeley)";
  1585. d32 4
  1586. d86 1
  1587. a86 1
  1588. spriteSaveCursorBox (xorg, yorg, mode, pPts, nPts, pCursorBox)
  1589. d91 1
  1590. d128 1
  1591. a128 1
  1592.     if (BOX_OVERLAP(pCursorBox,minx,miny,maxx,maxy)) {
  1593. d366 1
  1594. a366 1
  1595. void
  1596. d402 1
  1597. a402 1
  1598.     (* pShadowGC->CopyArea) (pSrc, pDst, pShadowGC, srcx, srcy,
  1599. d419 1
  1600. a419 1
  1601. void
  1602. d457 1
  1603. a457 1
  1604.     (* pShadowGC->CopyPlane) (pSrc, pDst, pShadowGC, srcx, srcy, w, h,
  1605. d545 1
  1606. d729 1
  1607. @
  1608.  
  1609.  
  1610. 1.7
  1611. log
  1612. @lots o' changes to match R1 and patches to sun code
  1613. @
  1614. text
  1615. @d20 1
  1616. a20 1
  1617.     "$Header: spriteGC.c,v 1.6 87/08/04 17:30:39 deboor Exp $ SPRITE (Berkeley)";
  1618. d66 1
  1619. a66 1
  1620.      ((WindowPtr)(pDraw))->realized && \
  1621. d902 1
  1622. a902 1
  1623.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->realized) {
  1624. d930 1
  1625. a930 1
  1626.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->realized) {
  1627. d961 1
  1628. a961 1
  1629.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->realized) {
  1630. d989 1
  1631. a989 1
  1632.     if ((pDraw->type == DRAWABLE_WINDOW) && ((WindowPtr)pDraw)->realized) {
  1633. d1203 4
  1634. a1206 1
  1635.  *    Ditto for copying the clipping region of the GC.
  1636. d1223 8
  1637. @
  1638.  
  1639.  
  1640. 1.6
  1641. log
  1642. @?
  1643. @
  1644. text
  1645. @d20 1
  1646. a20 1
  1647.     "$Header: spriteGC.c,v 1.5 87/06/30 19:09:41 deboor Exp $ SPRITE (Berkeley)";
  1648. d31 1
  1649. d902 1
  1650. a902 1
  1651.     if (pDraw->type == DRAWABLE_WINDOW) {
  1652. d930 1
  1653. a930 1
  1654.     if (pDraw->type == DRAWABLE_WINDOW) {
  1655. d961 1
  1656. a961 1
  1657.     if (pDraw->type == DRAWABLE_WINDOW) {
  1658. d989 1
  1659. a989 1
  1660.     if (pDraw->type == DRAWABLE_WINDOW) {
  1661. d1118 109
  1662. d1276 7
  1663. d1313 1
  1664. a1313 1
  1665.     CopyGC (pGCSrc, (GCPtr) pGCDst->devPriv, changes);
  1666. a1315 22
  1667. /*-
  1668.  *-----------------------------------------------------------------------
  1669.  * spriteChangeClip --
  1670.  *    Front end for changing the clip in the GC. Just passes the command
  1671.  *    on through the shadow GC.
  1672.  *
  1673.  * Results:
  1674.  *    None.
  1675.  *
  1676.  * Side Effects:
  1677.  *    ???
  1678.  *
  1679.  *-----------------------------------------------------------------------
  1680.  */
  1681. void
  1682. spriteChangeClip (pGC, type, pValue, numRects)
  1683.     GCPtr         pGC;
  1684.     int              type;
  1685.     pointer       pValue;
  1686.     int              numRects;
  1687. {
  1688.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  1689. a1316 25
  1690.     (* pShadowGC->ChangeClip) (pShadowGC, type, pValue, numRects);
  1691. }
  1692.  
  1693. /*-
  1694.  *-----------------------------------------------------------------------
  1695.  * spriteDestroyClip --
  1696.  *    Ditto for destroying the clipping region of the GC.
  1697.  *
  1698.  * Results:
  1699.  *    None.
  1700.  *
  1701.  * Side Effects:
  1702.  *    ???
  1703.  *
  1704.  *-----------------------------------------------------------------------
  1705.  */
  1706. void
  1707. spriteDestroyClip (pGC)
  1708.     GCPtr   pGC;
  1709. {
  1710.     register GCPtr pShadowGC = (GCPtr) pGC->devPriv;
  1711.  
  1712.     (* pShadowGC->DestroyClip) (pShadowGC);
  1713. }
  1714.  
  1715. d1342 5
  1716. a1346 1
  1717.     spritePushPixels
  1718. d1413 1
  1719. a1431 2
  1720.     pGC->ChangeClip = spriteChangeClip;
  1721.     pGC->DestroyClip = spriteDestroyClip;
  1722. d1443 1
  1723. a1443 1
  1724.      *  pCompositeClip, pAbsClientRegion.
  1725. d1454 6
  1726. @
  1727.  
  1728.  
  1729. 1.5
  1730. log
  1731. @Changed spriteCreatePrivGC to just use CreateGC, since
  1732. CreateScratchGC has been taken away.
  1733. @
  1734. text
  1735. @d20 1
  1736. a20 1
  1737.     "$Header: spriteGC.c,v 1.4 87/06/28 14:21:24 deboor Exp $ SPRITE (Berkeley)";
  1738. d852 7
  1739. a858 2
  1740.     if (spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  1741.     QueryGlyphExtents(pGC->font, charinfo, count, &extents);
  1742. d860 3
  1743. a862 2
  1744.     xorg = ((WindowPtr)pDraw)->absCorner.x;
  1745.     yorg = ((WindowPtr)pDraw)->absCorner.y;
  1746. d864 7
  1747. a870 6
  1748.     if (BOX_OVERLAP(&cursorBox,
  1749.             x + xorg + extents.overallLeft,
  1750.             y + yorg - extents.overallAscent,
  1751.             x + xorg + extents.overallRight,
  1752.             y + yorg + extents.overallDescent)) {
  1753.                 spriteRemoveCursor();
  1754. d872 1
  1755. a876 4
  1756.     if (n != 0) {
  1757.         (* drawFunc)(pDraw, pGC, x, y, n, charinfo, pGC->font->pGlyphs);
  1758.     }
  1759.  
  1760. d1135 2
  1761. a1136 1
  1762.     FreeGC ((GCPtr)pGC->devPriv);
  1763. d1164 3
  1764. d1307 1
  1765. a1307 1
  1766.     pGC = CreateGC (pDrawable, mask, pval, pStatus);
  1767. d1342 7
  1768. @
  1769.  
  1770.  
  1771. 1.4
  1772. log
  1773. @Nuked region checking b/c it tended to stop checking when the
  1774. cursor went on a child of the root window. Not good.
  1775. @
  1776. text
  1777. @d20 1
  1778. a20 1
  1779.     "$Header: spriteGC.c,v 1.3 87/06/24 12:52:26 deboor Exp $ SPRITE (Berkeley)";
  1780. d1299 1
  1781. a1299 1
  1782.     pGC = CreateScratchGC (pDrawable, mask, pval, pStatus);
  1783. @
  1784.  
  1785.  
  1786. 1.3
  1787. log
  1788. @Nothing, really
  1789. @
  1790. text
  1791. @d20 1
  1792. a20 1
  1793.     "$Header: spriteGC.c,v 1.2 87/06/21 19:13:35 deboor Exp $ SPRITE (Berkeley)";
  1794. d58 4
  1795. a61 2
  1796.  * be realized and on the same screen as the cursor and the cursor box
  1797.  * must overlap the clipping region of the window. 
  1798. d66 1
  1799. a66 3
  1800.      spriteCursorLoc ((((DrawablePtr)(pDraw))->pScreen), &cursorBox) && \
  1801.      ((* ((DrawablePtr)(pDraw))->pScreen->RectIn) \
  1802.               (((WindowPtr)(pDraw))->borderClip, &cursorBox) != rgnOUT))
  1803. @
  1804.  
  1805.  
  1806. 1.2
  1807. log
  1808. @Fixed mouse turds and macro-ized everything to make
  1809. other fixes easier...
  1810. @
  1811. text
  1812. @d20 1
  1813. a20 1
  1814.     "$Header: spriteGC.c,v 1.1 87/06/20 14:55:42 deboor Exp $ SPRITE (Berkeley)";
  1815. d56 12
  1816. d90 4
  1817. a93 4
  1818.     register int          minx,
  1819.                 miny,
  1820.                 maxx,
  1821.                 maxy;
  1822. d151 1
  1823. d153 12
  1824. a164 16
  1825.     if (pDrawable->type == DRAWABLE_WINDOW) {
  1826.     BoxRec      cursorBox;
  1827.  
  1828.     if (spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  1829.         register DDXPointPtr    pts;
  1830.         register int            *widths;
  1831.         register int            nPts;
  1832.  
  1833.         for (pts = pptInit, widths = pwidthInit, nPts = nInit;
  1834.          nPts--;
  1835.          pts++, widths++) {
  1836.              if (SPN_OVERLAP(&cursorBox,pts->y,pts->x,*widths)) {
  1837.              spriteRemoveCursor();
  1838.              break;
  1839.              }
  1840.         }
  1841. d197 1
  1842. d199 12
  1843. a210 16
  1844.     if (pDrawable->type == DRAWABLE_WINDOW) {
  1845.     BoxRec      cursorBox;
  1846.  
  1847.     if (spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  1848.         register DDXPointPtr    pts;
  1849.         register int            *widths;
  1850.         register int            nPts;
  1851.  
  1852.         for (pts = ppt, widths = pwidth, nPts = nspans;
  1853.          nPts--;
  1854.          pts++, widths++) {
  1855.              if (SPN_OVERLAP(&cursorBox,pts->y,pts->x,*widths)) {
  1856.              spriteRemoveCursor();
  1857.              break;
  1858.              }
  1859.         }
  1860. d221 1
  1861. a221 1
  1862.  *    Remove the cursor if any of the desired spans overlaps the cursor.
  1863. d237 1
  1864. a237 2
  1865.     if (pDrawable->type == DRAWABLE_WINDOW) {
  1866.     BoxRec      cursorBox;
  1867. d239 5
  1868. a243 5
  1869.     if (spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  1870.         register DDXPointPtr    pts;
  1871.         register int            *widths;
  1872.         register int            nPts;
  1873.         register int            xorg,
  1874. d245 12
  1875. a256 13
  1876.  
  1877.         xorg = ((WindowPtr)pDrawable)->absCorner.x;
  1878.         yorg = ((WindowPtr)pDrawable)->absCorner.y;
  1879.  
  1880.         for (pts = ppt, widths = pwidth, nPts = nspans;
  1881.          nPts--;
  1882.          pts++, widths++) {
  1883.              if (SPN_OVERLAP(&cursorBox,pts->y+yorg,
  1884.                      pts->x+xorg,*widths)) {
  1885.                      spriteRemoveCursor();
  1886.                      break;
  1887.              }
  1888.         }
  1889. d295 1
  1890. d297 2
  1891. a298 4
  1892.     if (pDst->type == DRAWABLE_WINDOW) {
  1893.     BoxRec      cursorBox;
  1894.     if (spriteCursorLoc (pDst->pScreen, &cursorBox)) {
  1895.         register WindowPtr pWin = (WindowPtr)pDst;
  1896. d300 3
  1897. a302 4
  1898.         if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  1899.                 x,y,w,h)) {
  1900.                 spriteRemoveCursor();
  1901.         }
  1902. d333 7
  1903. a339 10
  1904.     if (pSrc->type == DRAWABLE_WINDOW) {
  1905.     BoxRec      cursorBox;
  1906.  
  1907.     if (spriteCursorLoc(pSrc->pScreen, &cursorBox)) {
  1908.         register WindowPtr    pWin = (WindowPtr)pSrc;
  1909.  
  1910.         if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  1911.                 x,y,w,h)) {
  1912.                 spriteRemoveCursor();
  1913.         }
  1914. d377 2
  1915. a378 3
  1916.     if (pSrc->type == DRAWABLE_WINDOW &&
  1917.     spriteCursorLoc(pSrc->pScreen, &cursorBox)) {
  1918.         pWin = (WindowPtr)pSrc;
  1919. d380 5
  1920. a384 5
  1921.         if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  1922.                 srcx, srcy, w, h)) {
  1923.                 spriteRemoveCursor();
  1924.                 out = TRUE;
  1925.         }
  1926. d387 2
  1927. a388 3
  1928.     if (!out && pDst->type == DRAWABLE_WINDOW &&
  1929.     spriteCursorLoc(pDst->pScreen, &cursorBox)) {
  1930.         pWin = (WindowPtr)pDst;
  1931. d390 4
  1932. a393 4
  1933.         if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  1934.                 dstx, dsty, w, h)) {
  1935.                 spriteRemoveCursor();
  1936.         }
  1937. d431 2
  1938. a432 3
  1939.     if (pSrc->type == DRAWABLE_WINDOW &&
  1940.     spriteCursorLoc(pSrc->pScreen, &cursorBox)) {
  1941.         pWin = (WindowPtr)pSrc;
  1942. d434 5
  1943. a438 5
  1944.         if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  1945.                 srcx, srcy, w, h)) {
  1946.                 spriteRemoveCursor();
  1947.                 out = TRUE;
  1948.         }
  1949. d441 7
  1950. a447 8
  1951.     if (!out && pDst->type == DRAWABLE_WINDOW &&
  1952.     spriteCursorLoc(pDst->pScreen, &cursorBox)) {
  1953.         pWin = (WindowPtr)pDst;
  1954.         
  1955.         if (ORG_OVERLAP(&cursorBox,pWin->absCorner.x,pWin->absCorner.y,
  1956.                 dstx, dsty, w, h)) {
  1957.                 spriteRemoveCursor();
  1958.         }
  1959. d484 9
  1960. a492 11
  1961.     if (pDrawable->type == DRAWABLE_WINDOW &&
  1962.     spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  1963.         xorg = ((WindowPtr)pDrawable)->absCorner.x;
  1964.         yorg = ((WindowPtr)pDrawable)->absCorner.y;
  1965.  
  1966.         if (mode == CoordModeOrigin) {
  1967.         for (pts = pptInit, nPts = npt; nPts--; pts++) {
  1968.             if (ORG_OVERLAP(&cursorBox,xorg,yorg,pts->x,pts->y,0,0)){
  1969.             spriteRemoveCursor();
  1970.             break;
  1971.             }
  1972. d494 9
  1973. a502 9
  1974.         } else {
  1975.         for (pts = pptInit, nPts = npt; nPts--; pts++) {
  1976.             if (ORG_OVERLAP(&cursorBox,xorg,yorg,pts->x,pts->y,0,0)){
  1977.             spriteRemoveCursor();
  1978.             break;
  1979.             } else {
  1980.             xorg += pts->x;
  1981.             yorg += pts->y;
  1982.             }
  1983. d505 1
  1984. d535 7
  1985. a541 8
  1986.     if (pDrawable->type == DRAWABLE_WINDOW &&
  1987.     spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  1988.         spriteSaveCursorBox(((WindowPtr)pDrawable)->absCorner.x,
  1989.                  ((WindowPtr)pDrawable)->absCorner.y,
  1990.                  mode,
  1991.                  pptInit,
  1992.                  npt,
  1993.                  &cursorBox);
  1994. d577 7
  1995. a583 17
  1996.     if (pDraw->type == DRAWABLE_WINDOW &&
  1997.     spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  1998.         xorg = ((WindowPtr)pDraw)->absCorner.x;
  1999.         yorg = ((WindowPtr)pDraw)->absCorner.y;
  2000.  
  2001.         for (nSeg = nseg, pSeg = pSegs; nSeg--; pSeg++) {
  2002.         if (pSeg->x1 < pSeg->x2) {
  2003.             if (pSeg->y1 < pSeg->y2) {
  2004.             nuke = BOX_OVERLAP(&cursorBox,
  2005.                        pSeg->x1+xorg,pSeg->y1+yorg,
  2006.                        pSeg->x2+xorg,pSeg->y2+yorg);
  2007.             } else {
  2008.             nuke = BOX_OVERLAP(&cursorBox,
  2009.                        pSeg->x1+xorg,pSeg->y2+yorg,
  2010.                        pSeg->x2+xorg,pSeg->y1+yorg);
  2011.             }
  2012.         } else if (pSeg->y1 < pSeg->y2) {
  2013. d585 2
  2014. a586 2
  2015.                        pSeg->x2+xorg,pSeg->y1+yorg,
  2016.                        pSeg->x1+xorg,pSeg->y2+yorg);
  2017. d589 2
  2018. a590 2
  2019.                        pSeg->x2+xorg,pSeg->y2+yorg,
  2020.                        pSeg->x1+xorg,pSeg->y1+yorg);
  2021. d592 8
  2022. a599 4
  2023.         if (nuke) {
  2024.             spriteRemoveCursor();
  2025.             break;
  2026.         }
  2027. d601 5
  2028. d638 8
  2029. a645 10
  2030.     if (pDraw->type == DRAWABLE_WINDOW &&
  2031.     spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  2032.         xorg = ((WindowPtr)pDraw)->absCorner.x;
  2033.         yorg = ((WindowPtr)pDraw)->absCorner.y;
  2034.  
  2035.         for (nRect = nrects, pRect = pRects; nRect--; pRect++) {
  2036.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pRect)){
  2037.             spriteRemoveCursor();
  2038.             break;
  2039.         }
  2040. d647 1
  2041. d679 8
  2042. a686 10
  2043.     if (pDraw->type == DRAWABLE_WINDOW &&
  2044.     spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  2045.         xorg = ((WindowPtr)pDraw)->absCorner.x;
  2046.         yorg = ((WindowPtr)pDraw)->absCorner.y;
  2047.  
  2048.         for (nArc = narcs, pArc = parcs; nArc--; pArc++) {
  2049.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pArc)){
  2050.             spriteRemoveCursor();
  2051.             break;
  2052.         }
  2053. d688 1
  2054. d718 7
  2055. a724 8
  2056.     if (pDraw->type == DRAWABLE_WINDOW &&
  2057.     spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  2058.         spriteSaveCursorBox(((WindowPtr)pDraw)->absCorner.x,
  2059.                  ((WindowPtr)pDraw)->absCorner.y,
  2060.                  mode,
  2061.                  pPts,
  2062.                  count,
  2063.                  &cursorBox);
  2064. d757 8
  2065. a764 10
  2066.     if (pDrawable->type == DRAWABLE_WINDOW &&
  2067.     spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  2068.         xorg = ((WindowPtr)pDrawable)->absCorner.x;
  2069.         yorg = ((WindowPtr)pDrawable)->absCorner.y;
  2070.  
  2071.         for (nRect = nrectFill, pRect = prectInit; nRect--; pRect++) {
  2072.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pRect)){
  2073.             spriteRemoveCursor();
  2074.             break;
  2075.         }
  2076. d766 1
  2077. d799 8
  2078. a806 10
  2079.     if (pDraw->type == DRAWABLE_WINDOW &&
  2080.     spriteCursorLoc (pDraw->pScreen, &cursorBox)) {
  2081.         xorg = ((WindowPtr)pDraw)->absCorner.x;
  2082.         yorg = ((WindowPtr)pDraw)->absCorner.y;
  2083.  
  2084.         for (nArc = narcs, pArc = parcs; nArc--; pArc++) {
  2085.         if (ORGRECT_OVERLAP(&cursorBox,xorg,yorg,pArc)){
  2086.             spriteRemoveCursor();
  2087.             break;
  2088.         }
  2089. d808 1
  2090. d986 3
  2091. a988 3
  2092.             (pShadowGC->font->pFI->lastRow == 0 ?
  2093.              Linear16Bit : TwoD16Bit),
  2094.             pShadowGC->ImageGlyphBlt);
  2095. d1019 10
  2096. a1028 11
  2097.     if (pDrawable->type == DRAWABLE_WINDOW &&
  2098.     spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  2099.         QueryGlyphExtents (pGC->font, ppci, nglyph, &extents);
  2100.         xorg = ((WindowPtr)pDrawable)->absCorner.x + x;
  2101.         yorg = ((WindowPtr)pDrawable)->absCorner.y + y;
  2102.         if (BOX_OVERLAP(&cursorBox,xorg+extents.overallLeft,
  2103.                 yorg+extents.overallAscent,
  2104.                 xorg+extents.overallRight,
  2105.                 yorg+extents.overallDescent)) {
  2106.                 spriteRemoveCursor();
  2107.         }
  2108. d1060 10
  2109. a1069 11
  2110.     if (pDrawable->type == DRAWABLE_WINDOW &&
  2111.     spriteCursorLoc (pDrawable->pScreen, &cursorBox)) {
  2112.         QueryGlyphExtents (pGC->font, ppci, nglyph, &extents);
  2113.         xorg = ((WindowPtr)pDrawable)->absCorner.x + x;
  2114.         yorg = ((WindowPtr)pDrawable)->absCorner.y + y;
  2115.         if (BOX_OVERLAP(&cursorBox,xorg+extents.overallLeft,
  2116.                 yorg+extents.overallAscent,
  2117.                 xorg+extents.overallRight,
  2118.                 yorg+extents.overallDescent)){
  2119.                 spriteRemoveCursor();
  2120.         }
  2121. d1099 7
  2122. a1105 8
  2123.     if (pDst->type == DRAWABLE_WINDOW &&
  2124.     spriteCursorLoc (pDst->pScreen, &cursorBox)) {
  2125.         xorg = ((WindowPtr)pDst)->absCorner.x + x;
  2126.         yorg = ((WindowPtr)pDst)->absCorner.y + y;
  2127.  
  2128.         if (BOX_OVERLAP(&cursorBox,xorg,yorg,xorg+w,yorg+h)){
  2129.         spriteRemoveCursor();
  2130.         }
  2131. d1191 48
  2132. d1342 2
  2133. d1367 1
  2134. a1367 15
  2135. #ifdef    notdef
  2136.     if (pGC->pCompositeClip) {
  2137.         pShadowGC->pCompositeClip =
  2138.         (* pGC->pScreen->RegionCreate) (NULL, 1);
  2139.         (* pGC->pScreen->RegionCopy) (pShadowGC->pCompositeClip,
  2140.                       pGC->pCompositeClip);
  2141.     }
  2142.     if (pGC->pAbsClientRegion) {
  2143.         pShadowGC->pAbsClientRegion=
  2144.         (* pGC->pScreen->RegionCreate) (NULL, 1);
  2145.         (* pGC->pScreen->RegionCopy) (pShadowGC->pAbsClientRegion,
  2146.                       pGC->pAbsClientRegion);
  2147.     }
  2148. #endif    notdef
  2149.     
  2150. @
  2151.  
  2152.  
  2153. 1.1
  2154. log
  2155. @Initial revision
  2156. @
  2157. text
  2158. @d20 1
  2159. a20 1
  2160.     "$Header: spriteGC.c,v 2.6 87/06/09 22:06:14 deboor Exp $ SPRITE (Berkeley)";
  2161. d32 6
  2162. d39 17
  2163. d98 2
  2164. a99 2
  2165.     xorg += minx;
  2166.     yorg += miny;
  2167. d110 2
  2168. a111 3
  2169.     if (minx < pCursorBox->x2 && pCursorBox->x1 < maxx &&
  2170.     miny < pCursorBox->y2 && pCursorBox->y1 < maxy) {
  2171.         spriteRemoveCursor();
  2172. d151 3
  2173. a153 5
  2174.              if (pts->y >= cursorBox.y1 && pts->y < cursorBox.y2 &&
  2175.              pts->x < cursorBox.x2 &&
  2176.              cursorBox.x1 < pts->x + *widths) {
  2177.                  spriteRemoveCursor();
  2178.                  break;
  2179. d200 3
  2180. a202 5
  2181.              if (pts->y >= cursorBox.y1 && pts->y < cursorBox.y2 &&
  2182.              pts->x < cursorBox.x2 &&
  2183.              cursorBox.x1 < pts->x + *widths) {
  2184.                  spriteRemoveCursor();
  2185.                  break;
  2186. d247 4
  2187. a250 6
  2188.              if (pts->y + yorg >= cursorBox.y1 &&
  2189.              pts->y + yorg < cursorBox.y2 &&
  2190.              pts->x + xorg < cursorBox.x2 &&
  2191.              cursorBox.x1 < pts->x + xorg + *widths) {
  2192.                  spriteRemoveCursor();
  2193.                  break;
  2194. d297 3
  2195. a299 5
  2196.         if (pWin->absCorner.x + x < cursorBox.x2 &&
  2197.         cursorBox.x1 < pWin->absCorner.x + x + w &&
  2198.         pWin->absCorner.y + y < cursorBox.y2 &&
  2199.         cursorBox.y1 < pWin->absCorner.y + y + h) {
  2200.             spriteRemoveCursor();
  2201. d337 3
  2202. a339 5
  2203.         if (pWin->absCorner.x + x < cursorBox.x2 &&
  2204.         cursorBox.x1 < pWin->absCorner.x + x + w &&
  2205.         pWin->absCorner.y + y < cursorBox.y2 &&
  2206.         cursorBox.y1 < pWin->absCorner.y + y + h) {
  2207.             spriteRemoveCursor();
  2208. d382 4
  2209. a385 6
  2210.         if (pWin->absCorner.x + srcx < cursorBox.x2 &&
  2211.         cursorBox.x1 < pWin->absCorner.x + srcx + w &&
  2212.         pWin->absCorner.y + srcy < cursorBox.y2 &&
  2213.         cursorBox.y1 < pWin->absCorner.y + srcy + h) {
  2214.             spriteRemoveCursor();
  2215.             out = TRUE;
  2216. d393 3
  2217. a395 5
  2218.         if (pWin->absCorner.x + dstx < cursorBox.x2 &&
  2219.         cursorBox.x1 < pWin->absCorner.x + dstx + w &&
  2220.         pWin->absCorner.y + dsty < cursorBox.y2 &&
  2221.         cursorBox.y1 < pWin->absCorner.y + dsty + h) {
  2222.             spriteRemoveCursor();
  2223. d438 4
  2224. a441 6
  2225.         if (pWin->absCorner.x + srcx < cursorBox.x2 &&
  2226.         cursorBox.x1 < pWin->absCorner.x + srcx + w &&
  2227.         pWin->absCorner.y + srcy < cursorBox.y2 &&
  2228.         cursorBox.y1 < pWin->absCorner.y + srcy + h) {
  2229.             spriteRemoveCursor();
  2230.             out = TRUE;
  2231. d449 3
  2232. a451 5
  2233.         if (pWin->absCorner.x + dstx < cursorBox.x2 &&
  2234.         cursorBox.x1 < pWin->absCorner.x + dstx + w &&
  2235.         pWin->absCorner.y + dsty < cursorBox.y2 &&
  2236.         cursorBox.y1 < pWin->absCorner.y + dsty + h) {
  2237.             spriteRemoveCursor();
  2238. d496 3
  2239. a498 6
  2240.             if (pts->x + xorg < cursorBox.x2 &&
  2241.             cursorBox.x1 <= pts->x + xorg &&
  2242.             pts->y + yorg < cursorBox.y2 &&
  2243.             cursorBox.y1 <= pts->y + yorg) {
  2244.                 spriteRemoveCursor();
  2245.                 break;
  2246. d503 3
  2247. a505 6
  2248.             if (pts->x + xorg < cursorBox.x2 &&
  2249.             cursorBox.x1 <= pts->x + xorg &&
  2250.             pts->y + yorg < cursorBox.y2 &&
  2251.             cursorBox.y1 <= pts->y + yorg) {
  2252.                 spriteRemoveCursor();
  2253.                 break;
  2254. d557 4
  2255. a560 1
  2256.  *    overlaps the cursor's area. Then draw the segments.
  2257. d582 1
  2258. d590 18
  2259. a607 6
  2260.         if (pSeg->x1 + xorg < cursorBox.x2 &&
  2261.             cursorBox.x1 < pSeg->x2 + xorg &&
  2262.             pSeg->y1 +yorg < cursorBox.y2 &&
  2263.             cursorBox.y1 < pSeg->y2 + yorg) {
  2264.             spriteRemoveCursor();
  2265.             break;
  2266. d609 4
  2267. d652 3
  2268. a654 6
  2269.         if (pRect->x + xorg < cursorBox.x2 &&
  2270.             cursorBox.x1 < pRect->x + xorg + pRect->width &&
  2271.             pRect->y + yorg < cursorBox.y2 &&
  2272.             cursorBox.y2 < pRect->y + yorg + pRect->height) {
  2273.             spriteRemoveCursor();
  2274.             break;
  2275. d694 3
  2276. a696 6
  2277.         if (pArc->x + xorg < cursorBox.x2 &&
  2278.             cursorBox.x1 < pArc->x + xorg + pArc->width &&
  2279.             pArc->y + yorg < cursorBox.y2 &&
  2280.             cursorBox.y2 < pArc->y + yorg + pArc->height) {
  2281.             spriteRemoveCursor();
  2282.             break;
  2283. d774 3
  2284. a776 6
  2285.         if (pRect->x + xorg < cursorBox.x2 &&
  2286.             cursorBox.x1 < pRect->x + xorg + pRect->width &&
  2287.             pRect->y + yorg < cursorBox.y2 &&
  2288.             cursorBox.y1 < pRect->y + yorg + pRect->height) {
  2289.             spriteRemoveCursor();
  2290.             break;
  2291. d817 3
  2292. a819 6
  2293.         if (pArc->x + xorg < cursorBox.x2 &&
  2294.             cursorBox.x1 < pArc->x + xorg + pArc->width &&
  2295.             pArc->y + yorg < cursorBox.y2 &&
  2296.             cursorBox.y2 < pArc->y + yorg + pArc->height) {
  2297.             spriteRemoveCursor();
  2298.             break;
  2299. d871 6
  2300. a876 5
  2301.     if (x + xorg + extents.overallLeft < cursorBox.x2 &&
  2302.         cursorBox.x1 < x + xorg + extents.overallRight &&
  2303.         y + yorg - extents.overallAscent < cursorBox.y2 &&
  2304.         cursorBox.y1 < y + yorg + extents.overallDescent) {
  2305.         spriteRemoveCursor();
  2306. d1037 5
  2307. a1041 5
  2308.         if (extents.overallLeft + xorg < cursorBox.x2 &&
  2309.         cursorBox.x1 < xorg + extents.overallRight &&
  2310.         yorg - extents.overallAscent < cursorBox.y2 &&
  2311.         cursorBox.y1 < yorg + extents.overallDescent) {
  2312.             spriteRemoveCursor();
  2313. d1079 5
  2314. a1083 5
  2315.         if (extents.overallLeft + xorg < cursorBox.x2 &&
  2316.         cursorBox.x1 < xorg + extents.overallRight &&
  2317.         yorg - extents.overallAscent < cursorBox.y2 &&
  2318.         cursorBox.y1 < yorg + extents.overallDescent) {
  2319.             spriteRemoveCursor();
  2320. d1119 2
  2321. a1120 3
  2322.         if (xorg < cursorBox.x2 && cursorBox.x1 < xorg + w &&
  2323.         yorg < cursorBox.y2 && cursorBox.y1 < yorg + h) {
  2324.             spriteRemoveCursor();
  2325. @
  2326.